
struct-sizeof.o:     file format elf64-littleaarch64


Disassembly of section .text:

0000000000000000 <main>:
{
    char * gga;
};

void main()
{
   0:	a9bd7bfd 	stp	x29, x30, [sp, #-48]!
   4:	910003fd 	mov	x29, sp
    struct nema * p = NULL;
   8:	f90017bf 	str	xzr, [x29, #40]
    struct queue * qu = NULL; 
   c:	f90013bf 	str	xzr, [x29, #32]
    struct point p_a, * p_b;

    printf("struct size = %ld\n", sizeof(struct nema));   // 16
  10:	90000000 	adrp	x0, 0 <main>
  14:	91000000 	add	x0, x0, #0x0
  18:	d2800201 	mov	x1, #0x10                  	// #16
  1c:	94000000 	bl	0 <printf>
    printf("struct size = %ld\n", sizeof(struct queue));  // 24
  20:	90000000 	adrp	x0, 0 <main>
  24:	91000000 	add	x0, x0, #0x0
  28:	d2800301 	mov	x1, #0x18                  	// #24
  2c:	94000000 	bl	0 <printf>

    p = (struct nema *)malloc(sizeof(struct nema));
  30:	d2800200 	mov	x0, #0x10                  	// #16
  34:	94000000 	bl	0 <malloc>
  38:	f90017a0 	str	x0, [x29, #40]
    printf("struct size = %ld\n", sizeof(p));   // 8
  3c:	90000000 	adrp	x0, 0 <main>
  40:	91000000 	add	x0, x0, #0x0
  44:	d2800101 	mov	x1, #0x8                   	// #8
  48:	94000000 	bl	0 <printf>

    strcpy(p->gga, "abcdef");
  4c:	f94017a2 	ldr	x2, [x29, #40]
  50:	90000000 	adrp	x0, 0 <main>
  54:	91000001 	add	x1, x0, #0x0
  58:	aa0203e0 	mov	x0, x2
  5c:	b9400022 	ldr	w2, [x1]
  60:	b9000002 	str	w2, [x0]
  64:	b8403021 	ldur	w1, [x1, #3]
  68:	b8003001 	stur	w1, [x0, #3]
    printf("gga = %s\n", p->gga);  // abcdef
  6c:	f94017a1 	ldr	x1, [x29, #40]
  70:	90000000 	adrp	x0, 0 <main>
  74:	91000000 	add	x0, x0, #0x0
  78:	94000000 	bl	0 <printf>

    qu = (struct queue *) malloc (sizeof(struct queue));
  7c:	d2800300 	mov	x0, #0x18                  	// #24
  80:	94000000 	bl	0 <malloc>
  84:	f90013a0 	str	x0, [x29, #32]
    qu->queue = (struct nema *) malloc (sizeof(struct nema));
  88:	d2800200 	mov	x0, #0x10                  	// #16
  8c:	94000000 	bl	0 <malloc>
  90:	aa0003e1 	mov	x1, x0
  94:	f94013a0 	ldr	x0, [x29, #32]
  98:	f9000001 	str	x1, [x0]
    strcpy(qu->queue->gga, "xiaozhi");  // 没有上面一行会段出错
  9c:	f94013a0 	ldr	x0, [x29, #32]
  a0:	f9400000 	ldr	x0, [x0]
  a4:	aa0003e1 	mov	x1, x0
  a8:	90000000 	adrp	x0, 0 <main>
  ac:	91000000 	add	x0, x0, #0x0
  b0:	f9400000 	ldr	x0, [x0]
  b4:	f9000020 	str	x0, [x1]
    printf("queue->gga = %s\n", qu->queue->gga);
  b8:	f94013a0 	ldr	x0, [x29, #32]
  bc:	f9400000 	ldr	x0, [x0]
  c0:	aa0003e1 	mov	x1, x0
  c4:	90000000 	adrp	x0, 0 <main>
  c8:	91000000 	add	x0, x0, #0x0
  cc:	94000000 	bl	0 <printf>
    free(qu->queue);
  d0:	f94013a0 	ldr	x0, [x29, #32]
  d4:	f9400000 	ldr	x0, [x0]
  d8:	94000000 	bl	0 <free>
    qu->queue = NULL;
  dc:	f94013a0 	ldr	x0, [x29, #32]
  e0:	f900001f 	str	xzr, [x0]

    qu->queue = p;
  e4:	f94013a0 	ldr	x0, [x29, #32]
  e8:	f94017a1 	ldr	x1, [x29, #40]
  ec:	f9000001 	str	x1, [x0]
    printf("queue->gga = %s\n", qu->queue->gga);  // abcdef
  f0:	f94013a0 	ldr	x0, [x29, #32]
  f4:	f9400000 	ldr	x0, [x0]
  f8:	aa0003e1 	mov	x1, x0
  fc:	90000000 	adrp	x0, 0 <main>
 100:	91000000 	add	x0, x0, #0x0
 104:	94000000 	bl	0 <printf>

    printf("struct point size = %ld\n", sizeof(struct point));  // 8
 108:	90000000 	adrp	x0, 0 <main>
 10c:	91000000 	add	x0, x0, #0x0
 110:	d2800101 	mov	x1, #0x8                   	// #8
 114:	94000000 	bl	0 <printf>
    
    p_a.gga = "eeef";
 118:	90000000 	adrp	x0, 0 <main>
 11c:	91000000 	add	x0, x0, #0x0
 120:	f9000ba0 	str	x0, [x29, #16]
    printf("p_a.gga = %s\n", p_a.gga);   // eeef
 124:	f9400ba1 	ldr	x1, [x29, #16]
 128:	90000000 	adrp	x0, 0 <main>
 12c:	91000000 	add	x0, x0, #0x0
 130:	94000000 	bl	0 <printf>

    p_a.gga = "fffa";
 134:	90000000 	adrp	x0, 0 <main>
 138:	91000000 	add	x0, x0, #0x0
 13c:	f9000ba0 	str	x0, [x29, #16]
    printf("p_a.gga = %s\n", p_a.gga);   // fffa
 140:	f9400ba1 	ldr	x1, [x29, #16]
 144:	90000000 	adrp	x0, 0 <main>
 148:	91000000 	add	x0, x0, #0x0
 14c:	94000000 	bl	0 <printf>

    //p_b->gga = "llkjl";
    //printf("p_b->gga = %s\n", p_b->gga);  // segmentation fault

    p_b = (struct point *) malloc (sizeof(struct point));
 150:	d2800100 	mov	x0, #0x8                   	// #8
 154:	94000000 	bl	0 <malloc>
 158:	f9000fa0 	str	x0, [x29, #24]
    p_b->gga = "llkjlasdfasdfasdfasdfasdfads";
 15c:	f9400fa0 	ldr	x0, [x29, #24]
 160:	90000001 	adrp	x1, 0 <main>
 164:	91000021 	add	x1, x1, #0x0
 168:	f9000001 	str	x1, [x0]
    printf("p_b->gga = %s\n", p_b->gga);  // llkjlasdfasdfasdfasdfasdfads
 16c:	f9400fa0 	ldr	x0, [x29, #24]
 170:	f9400001 	ldr	x1, [x0]
 174:	90000000 	adrp	x0, 0 <main>
 178:	91000000 	add	x0, x0, #0x0
 17c:	94000000 	bl	0 <printf>
    // strcpy(p_b->gga, "hello asm\n");      // segmentation fault
    // printf("p_b->gga = %s\n", p_b->gga);

    p_b->gga = p_a.gga;
 180:	f9400ba1 	ldr	x1, [x29, #16]
 184:	f9400fa0 	ldr	x0, [x29, #24]
 188:	f9000001 	str	x1, [x0]
    printf("p_b->gga = %s\n", p_b->gga);    // fffa
 18c:	f9400fa0 	ldr	x0, [x29, #24]
 190:	f9400001 	ldr	x1, [x0]
 194:	90000000 	adrp	x0, 0 <main>
 198:	91000000 	add	x0, x0, #0x0
 19c:	94000000 	bl	0 <printf>

    p_b->gga = (char *) malloc (sizeof(char) * 32);
 1a0:	d2800400 	mov	x0, #0x20                  	// #32
 1a4:	94000000 	bl	0 <malloc>
 1a8:	aa0003e1 	mov	x1, x0
 1ac:	f9400fa0 	ldr	x0, [x29, #24]
 1b0:	f9000001 	str	x1, [x0]
    //p_b->gga = "kkkkkkkk"; // 使用这种时无需申请内存，用它上面的代码直接用，指向这串字符串
    //printf("p_b->gga = %s\n", p_b->gga);  // kkkkkkk
    strcpy(p_b->gga, "hello asm");          // 开启上面的注释代码，strcpy将会s fault, 因为指向一段匿名内存后不可更改。 
 1b4:	f9400fa0 	ldr	x0, [x29, #24]
 1b8:	f9400002 	ldr	x2, [x0]
 1bc:	90000000 	adrp	x0, 0 <main>
 1c0:	91000001 	add	x1, x0, #0x0
 1c4:	aa0203e0 	mov	x0, x2
 1c8:	f9400022 	ldr	x2, [x1]
 1cc:	f9000002 	str	x2, [x0]
 1d0:	79401021 	ldrh	w1, [x1, #8]
 1d4:	79001001 	strh	w1, [x0, #8]
    printf("p_b->gga = %s\n", p_b->gga);    // hello asm
 1d8:	f9400fa0 	ldr	x0, [x29, #24]
 1dc:	f9400001 	ldr	x1, [x0]
 1e0:	90000000 	adrp	x0, 0 <main>
 1e4:	91000000 	add	x0, x0, #0x0
 1e8:	94000000 	bl	0 <printf>

    p_b->gga = p_a.gga;
 1ec:	f9400ba1 	ldr	x1, [x29, #16]
 1f0:	f9400fa0 	ldr	x0, [x29, #24]
 1f4:	f9000001 	str	x1, [x0]
    printf("p_b->gga = %s\n", p_b->gga);    // fffa
 1f8:	f9400fa0 	ldr	x0, [x29, #24]
 1fc:	f9400001 	ldr	x1, [x0]
 200:	90000000 	adrp	x0, 0 <main>
 204:	91000000 	add	x0, x0, #0x0
 208:	94000000 	bl	0 <printf>

    strcpy(p_b->gga, "ac asm");             // segmentation fault. because malloc address lose 
 20c:	f9400fa0 	ldr	x0, [x29, #24]
 210:	f9400002 	ldr	x2, [x0]
 214:	90000000 	adrp	x0, 0 <main>
 218:	91000001 	add	x1, x0, #0x0
 21c:	aa0203e0 	mov	x0, x2
 220:	b9400022 	ldr	w2, [x1]
 224:	b9000002 	str	w2, [x0]
 228:	b8403021 	ldur	w1, [x1, #3]
 22c:	b8003001 	stur	w1, [x0, #3]
    printf("p_b->gga = %s\n", p_b->gga);    // 
 230:	f9400fa0 	ldr	x0, [x29, #24]
 234:	f9400001 	ldr	x1, [x0]
 238:	90000000 	adrp	x0, 0 <main>
 23c:	91000000 	add	x0, x0, #0x0
 240:	94000000 	bl	0 <printf>

}
 244:	d503201f 	nop
 248:	a8c37bfd 	ldp	x29, x30, [sp], #48
 24c:	d65f03c0 	ret
